home *** CD-ROM | disk | FTP | other *** search
- #define DISABLE_LOCAL_CALLTRACE 1 // Set to 1 to disable Call Traces for this file.
- #define DISABLE_LOCAL_DEBUG 0 // Set to 1 to disable all debugging for this file.
- #include "DebugUtils.h"
-
- #include <Resources.h>
- #include "ContextUtils.h"
- #include "Nub.h"
-
-
-
-
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- OSStatus main(void);
- static Boolean isPressed(UInt8 keyCode);
-
- #ifdef __cplusplus
- }
- #endif
-
-
- #define CONTROL_KEY 0x3B
- #define OPTION_KEY 0x3A
- #define D_KEY 0x02
- #define S_KEY 0x01
-
-
-
-
-
- OSStatus main(void)
- {
- GlobalContext globals;
- THzContext zone(SystemZone());
- Handle code;
- OSStatus err;
-
-
- // Check and break.
- #if DEBUG
- if (isPressed(CONTROL_KEY) && isPressed(OPTION_KEY) && isPressed(D_KEY) && isPressed(S_KEY))
- DebugStr("\pNub> Thank you for holding down CONTROL-OPTION-D-S");
- #endif
-
- // Load the nub code resource.
- code = Get1Resource('nub ',0);
- if (code == NULL)
- {
- dprintf(kDConPrefix "Get1Resource('nub ',0) failed: %ld\n",ResError());
- return -1;
- }
-
- // Detach and lock code resource
- // so we can safely call it.
- DetachResource(code);
- HLock(code);
-
- // Call the main entry point.
- err = CallNubLoadProc((NubLoadUPP)(*code),code);
- if (err != noErr)
- {
- dprintf(kDConPrefix "NubLoad failed: %ld %s:%d\n",err);
- DisposeHandle(code);
- }
-
- return err;
- }
-
-
-
-
-
- Boolean isPressed(UInt8 keyCode)
- {
- UInt8 km[16];
-
-
- GetKeys((SInt32*)&km[0]);
- return ((km[keyCode >> 3] >> (keyCode & 7)) & 1);
- }
-